
<%- include ('../public/page_header.html') %>
<div class="">
  <ol class="breadcrumb">
    <li>修改管理员</li>
  </ol>
  <form action="/admin/manager/doEdit" method="post" id="form">
    <input type="hidden" name="id" value="<%=list._id%>">
    <div class="form-group row">
      <label for="username" class="col-sm-2">管理员名称：</label>
      <div class="col-sm-10"><input type="text" class="form-control" name="username" id="username" readonly value="<%=list.username%>"></div>
    </div>
    <div class="form-group row">
      <label for="password" class="col-sm-2">管理员密码：</label>
      <div class="col-sm-10"><input type="password" class="form-control" name="password" id="password">
      <span>说明：如果密码为空表示不修改管理员密码</span></div>
    </div>
    <div class="form-group row">
      <label for="rpassword" class="col-sm-2">确认密码：</label>
      <div class="col-sm-10"><input type="password" class="form-control" name="rpassword" id="rpassword"></div>
    </div>
    <div class="form-group row">
      <label for="phone" class="col-sm-2">管理员电话：</label>
      <div class="col-sm-10"><input type="tel" class="form-control" name="phone" id="phone" value="<%=list.phone%>"></div>
    </div>
    <div class="form-group row">
      <label for="email" class="col-sm-2">管理员邮箱：</label>
      <div class="col-sm-10"><input type="email" class="form-control" name="email" id="email" value="<%=list.email%>"></div>
    </div>
    <div class="form-group mb-2 row">
      <label class="col-sm-2">状态：</label>
      <div class="form-check" class="col-sm-10">
        <input class="form-check-input" type="radio" name="state" id="exampleRadios1" value="1" <% if(list.state==1){ %> checked <% } %> />
        <label class="form-check-label" for="exampleRadios1">
          显示
        </label>
        &nbsp;&nbsp;&nbsp;
        <input class="form-check-input" type="radio" name="state" id="exampleRadios2" value="0" <% if(list.state==0){ %> checked <% } %> />
        <label class="form-check-label" for="exampleRadios2">
          隐藏
        </label>
      </div>
    </div>
    <div class="form-group row">
      <label class="col-sm-2"></label>
      <div class="col-sm-10">
        <div class="error text-danger"></div>
        <button type="submit" class="btn btn-primary btn-sm">提交</button></div>
    </div>
  </form>
</div>
<script>
  $('#form').submit(function() {
    var username = $('#username').val()
    var password = $('#password').val()
    var rpassword = $('#rpassword').val()

    if(username.length === 0) {
      $('.error').html('Error: 用户名不能为空')
      return false
    }
    if(password && password.length < 6 ) {
      $('.error').html('Error: 密码长度不能小于6位')
      return false
    }

    if(password !== rpassword ) {
      $('.error').html('Error: 密码和确认密码不一致')
      return false
    }
    if($('.error').html()) {
      $('.error').html('')
    }
    return true
  })
</script>
</body>
</html>